#!/usr/bin/make -f

# Ensure at build time that the library has no dependencies on undefined
# symbols, and speed up loading.
LDFLAGS = $(shell dpkg-buildflags --get LDFLAGS)
CPPFLAGS = $(shell dpkg-buildflags --get CPPFLAGS)
CXXFLAGS = $(shell dpkg-buildflags --get CXXFLAGS)
CFLAGS = $(shell dpkg-buildflags --get CFLAGS)
LDFLAGS += -Wl,-z,defs -Wl,--as-needed

DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH)
DEB_DH_INSTALL_ARGS := --sourcedir=debian/tmp
DEB_DH_STRIP_ARGS := --dbg-package=libccrtp3-dbg
DEB_INSTALL_DOCS_ALL :=
DEB_INSTALL_CHANGELOG_ALL := ChangeLog
DEBIAN_DIR := $(shell echo ${MAKEFILE_LIST} | awk '{print $$1}' | xargs dirname )

%:
	dh $@ --parallel --buildsystem=cmake

.PHONY: override_dh_strip override_dh_auto_configure

override_dh_strip:
	dh_strip $(DEB_DH_STRIP_ARGS)

override_dh_auto_configure:
	dh_auto_configure -- \
		-DCMAKE_INSTALL_SYSCONFDIR:PATH=/etc \
                -DCMAKE_INSTALL_LOCALSTATEDIR:PATH=/var \
                -DCMAKE_CXX_FLAGS="$(CPPFLAGS) $(CXXFLAGS)" \
                -DCMAKE_EXE_LINKER_FLAGS="$(LDFLAGS)" \
                -DCMAKE_SHARED_LINKER_FLAGS="$(LDFLAGS)"

